package thinkingInJava.final_;

class tClass{
	int i = 0;
	void print(){
		System.out.print("tClass: "+this.i);
	}
	void Set(int i){
		this.i = i;
	};
}

public class Final {
	void fun(int i){
		i = 2;
	}
	
	void fun2(final int i){
		//i = 3;The final local variable i cannot be assigned. It must be blank and not using a compound assignment
	}
	
	void fun3(String s){
		s = "321";
	}
	
	// 基本类型的 final 不能改值
	void fun4(final String s){
		//s = "321";The final local variable s cannot be assigned. It must be blank and not using a compound assignment
	}
	
	void fun5(tClass tc){
		tc = new tClass();
		tc.Set(44);
		tc.print();
	}
	
	// 对象类型 final 不能改引用，但可以改（内部属性）值，而 C++ const 是什么都不可改
	void fun6(final tClass tc){
		//tc = new tClass();The final local variable tc cannot be assigned. It must be blank and not using a compound assignment
		tc.Set(33);
		tc.print();
	}
}
